#include "ZListStatusWidget.h"

ZListStatusWidget::ZListStatusWidget(QWidget *parent) :
    QWidget(parent)
{
    // parent->setLayout(this);
    initUI();
}

void ZListStatusWidget::initUI()
{
    layout = new QVBoxLayout;
}

void ZListStatusWidget::add(const QString &name)
{
    BodyWidget *a = new BodyWidget(name);
    a->setMaximumSize(60,20);
    layout->addWidget(a);
    list.push_back(a);
}

BodyWidget::BodyWidget(const QString &name)
{
    initUI();
    des->setText(name);
}


//MU_INIT_TYPE
void BodyWidget::setStatus(MU_INIT_TYPE selected)
{
    switch (selected) {
    case MU_TY_FALSE:
        light->Error();
        break;
    case MU_TY_TRUE:
        light->Open();
        break;
    case MU_TY_RUNNING:
        light->Blink(true);
        break;
    case MU_TY_NONE:
        light->Default();
        break;
    case MU_TY_STOP:
        light->Close();
        break;
    }
}
void BodyWidget::initUI()
{
    light = new QLight;
    des = new QLabel;
    QHBoxLayout *layout = new QHBoxLayout();
    des->setText("adsdsds");
    layout->addWidget(des);
    layout->addStretch();
    layout->addWidget(light);
    this->setLayout(layout);
}
